/*
 * Animation.h
 *
 *  Created on: 2022��2��11��
 *      Author: TangJie
 */

#ifndef USERTASK_ANIMATION_H_
#define USERTASK_ANIMATION_H_

//#include "SysCommon.h"
#include "Cpu.h"

#define ANM_TIME_DELAY_SCALE      30  //ms

#define ANMPLAYER_STATE_INIT      0
#define ANMPLAYER_STATE_PLAYING   1
#define ANMPLAYER_STATE_PAUSE     2
#define ANMPLAYER_STATE_FINISH    3
#define ANMPLAYER_STATE_STOP      4

typedef struct
{
	uint8_t  u8Dev;
	uint8_t  u8Chn;
	uint16_t u16PwmDuty_Chn;
	uint16_t  u16TimeDelay;
}AnmStep_t;



typedef void(*AnmCallback)(void);
typedef struct
{
	uint16_t u16AnmTableSize;
	const AnmStep_t* pstAnmTable;
	AnmCallback pfStartCallback;    //
	AnmCallback pfFinishCallback;    //
	AnmCallback pfStopCallback;     //
}AnmPlayPara_t;
#define PLAYER_PARA_INIT_VALUE { 0,\
	                             NULL,\
								 NULL,\
								 NULL,\
								 NULL,}

typedef struct
{
	uint8_t  u8PlayerState;       //
	uint16_t u16AnmStepIndex;       //
	const AnmPlayPara_t* pstPlayPara;     
}AnmPlayerState_t;


typedef struct
{
	uint8_t u8dangermodel_state;
        uint8_t u8safetymodel_state;
        uint8_t u8keepmodel_state;
	uint8_t u8currentmodel;
        uint8_t u8requestmodel;
}STM_Chang_t;

#define PLAYER_STATE_INIT_VALUE {ANMPLAYER_STATE_FINISH, \
                                 0,\
								 NULL}





extern void Anm_Stop(void);

extern void Task_ProcessAnmStep(void);

extern void Anm_Play(AnmPlayPara_t* pstplayPara);

extern void Anm_ResetPlayPara(AnmPlayPara_t* pstpara);

extern const AnmStep_t* Anm_GetCurrentAnmTable(void);

void Anm_Finish();

#endif /* USERTASK_ANIMATION_H_ */
